23.1 Time Base Initialization
Following the establishment of the early security hardening mechanisms, the kernel transitions from baseline environmental setup to functional system deployment. The four configuration steps succeeding the execution of rand_initialize() and boot_init_stack_canary() mark the point where the kernel begins constructing its time metrics, performance monitoring, and multi-core communication capabilities. This section outlines the structural process of establishing the kernel's time base.
The function time_init() serves as a critical milestone for calibrating the system's hardware clocks. It invokes architecture-specific code blocks—such as the board-level init_time() function supplied by legacy ARM platforms, or the timer sub-modules configured via Device Tree clock nodes and the TIMER_OF_DECLARE macro—to fully initialize the physical system timers. Prior to this initialization block, the kernel's tracking of jiffies relies entirely on early rough estimations; only after this phase does the kernel gain access to an accurate real-world "wall time."
The routine time_init() is implemented independently within each architecture subdirectory. For 32-bit ARM processors, the function is declared within the source file git/arch/arm/kernel/time.c, and its definition is implemented as follows:
void __init time_init(void)
{
if (machine_desc->init_time) {
machine_desc->init_time();
} else {
#ifdef CONFIG_COMMON_CLK
of_clk_init(NULL);
#endif
timer_probe();
tick_setup_hrtimer_broadcast();
}
}
This routine utilizes an if-else branching control structure to maintain backward compatibility between the legacy Machine Descriptor paradigm and the modern Device Tree combined with the Common Clock Framework (CCF).
-
If the current board-level configuration file registers an explicit init_time callback hook, the routine triggers it directly. This configuration pattern is routinely encountered on older SoCs or legacy ARM devices that have not fully migrated to Device Tree architectures. Under this model, hardware vendors manually configure the baseline timer frequencies and register interrupt service routines within the hard-coded board files.
-
Conversely, if the system image is compiled with the common clock framework enabled via CONFIG_COMMON_CLK, the routine triggers of_clk_init(), which parses the firmware Device Tree nodes to bootstrap the entire clock tree hierarchy across the SoC. The call of_clk_init(NULL) starts tracking from the root node of the device tree, systematically traversing every sub-node decorated with clock-related management properties. Once the parsing engine uncovers a node whose compatible attribute matches an entry in the static clock driver matching table—registered at compile time via the CLK_OF_DECLARE macro layout—it executes the corresponding initialization callback handler supplied by that clock driver. The CLK_OF_DECLARE macro is utilized to embed clock controller driver linkages straight into the kernel image binary text. If the clock nodes within the device tree exhibit a nested, multi-tiered hierarchy, of_clk_init() resolves these dependencies and initializes the system clocks in their strict structural sequence.
Within the execution path of time_init(), the routine timer_probe() is dispatched immediately succeeding the conclusion of of_clk_init(), serving as the definitive milestone where the kernel formally takes over the underlying hardware timers.
If of_clk_init() is conceptually characterized as locating and exposing the raw system clock sources, then timer_probe() functions as the mechanism that "sets and winds up the alarm clock." Within the Linux device driver model, a probe() handler represents the central initialization callback function executed the moment a driver is successfully bound to a matching hardware device. When the kernel discovers that a physical device satisfies the configuration constraints specified within a driver's id_table or compatible field, it dispatches the driver's probe() callback. In short, the primary task of a probe() handler is to execute low-level device configuration and transition the hardware into a fully functional state.
timer_probe() is defined within the driver core source file git/drivers/clocksource/timer-probe.c. Its primary systemic objectives encompass pattern-matching timer hardware, invoking low-level timer driver callbacks, and establishing the baseline system clock references. timer_probe() first scans the active device tree layout to resolve timer nodes decorated with the compatible attribute, and queries a static matching table compiled via the TIMER_OF_DECLARE macro (the timer registration macro used to instantiate timer device drivers) to find a matching string descriptor. Upon successfully resolving a matching node, it fires the corresponding initialization callback handler implemented inside that timer driver. Following this configuration pass, the kernel successfully registers and binds both the low-level physical clock source hardware (struct clocksource) and the clock event device (struct clock_event_device).
The precise role of of_clk_init() is to prepare the infrastructure required by the Common Clock Framework, which it leverages to map and bootstrap the SoC's absolute clock tree hierarchy. This routine guarantees that all disparate clock nodes throughout the silicon die (including Phase-Locked Loops or PLLs, clock dividers, and hardware clock gates) are fully stabilized and functional. When the subsequent timer drivers execute their respective initialization callbacks, they typically demand a precise input frequency reference to calibrate their internal counters. The timer driver issues an API call to the common clock interface to harvest the verified clock signal previously registered and configured by of_clk_init().
Upon the conclusion of the timer_probe() block, the low-level physical timers actively commence incrementing their hardware counters and gain full authorization to assert hardware interrupts the moment an internal counter crosses its programmed expiration threshold. At this juncture, the kernel's clock tick infrastructure stands fully prepared, giving the kernel the time-slicing capability required to execute multi-tasking process scheduling.